import React from 'react'
import Controller from '../imvc/controller'

function View({ state }) {
  const { basename, paths } = state
  return (
    <div>
      <h1>All-Paths</h1>
      <ul>
        {paths.filter(path => path.indexOf(':') === -1 && path !== '*').map(path => (
          <li key={path}>
            <a href={basename + path}>{path}</a>
          </li>
        ))}
      </ul>
    </div>
  )
}

export default class extends Controller {
  View = View
  initialState = {
    dev: true,
  }
  getInitialState(finalInitialState) {
    const { basename, paths } = this.context
    return {
      ...finalInitialState,
      basename,
      paths,
    }
  }
}